var _hmt = _hmt || [];
;(function ($) {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?54053155f71955133eca53ea4c9da012";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        beforeSend: function (xhr,po) {
        },
        complete: function (XMLHttpRequest, textStatus) {
        },
        error: function () {
        }
    })
})(jQuery);


//判断是否是移动端
function g_isMobile() {
    if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
        return true;
    }
    else {
        return false;
    }
}


function postDataAjax(parameters) {
    var id = parameters.id;
    var type = parameters.type;
    var language = parameters.language;
    var url = parameters.url;
    var async = parameters.async;
    var cache = parameters.cache;
    var data = parameters.data;
    var dataType = parameters.dataType;
    if ("undefined" == typeof type) {
        type = "POST";
    }
    if ("undefined" == typeof language) {
        language = "chinese";
    }
    if ("undefined" == typeof async) {
        async = true;
    }
    if ("undefined" == typeof cache) {
        cache = false;
    }
    if ("undefined" == typeof dataType) {
        dataType = 'json';
    }

    //alert(url);
    if (language == "english") {
        load_text = '[ POST...... ]';
    } else {
        load_text = '[ 邮件发送中，请稍后...... ]';
    }

    $.ajax({
        //cache: true,
        type: type,
        url: url,
        data: data,
        dataType: dataType,
        //async: async,
        //processData: false,
        //contentType: false,
        beforeSend: function () {
            $("#" + id).html(load_text)
        },
        error: function (jqXHR, textStatus, errorThrown) {
            // alert("Error"+jqXHR.status+ " " + jqXHR.statusText);
            $("#" + id).html("[发送失败]");
        },
        success: function (msg) {
            $("#" + id).html(msg);
            //alert("success:"+msg.code+":"+msg.message);
            if (parseInt(msg.code) == 100)
                $("#" + id).html("[发送成功,期待您的光临]");
            else
                $("#" + id).html("[发送失败]");
        }
    });
}